// ============= Test Cases =============
import type { Alike, Expect } from './test-utils'

type cases = [
  Expect<Alike<MyReadonly2<Todo1>, Readonly<Todo1>>>,
  Expect<Alike<MyReadonly2<Todo1, 'title' | 'description'>, Expected>>,
  Expect<Alike<MyReadonly2<Todo2, 'title' | 'description'>, Expected>>,
  Expect<Alike<MyReadonly2<Todo2, 'description' >, Expected>>,
]

// @ts-expect-error
type error = MyReadonly2<Todo1, 'title' | 'invalid'>

interface Todo1 {
  title: string
  description?: string
  completed: boolean
}

interface Todo2 {
  readonly title: string
  description?: string
  completed: boolean
}

interface Expected {
  readonly title: string
  readonly description?: string
  completed: boolean
}


// ============= Your Code Here =============
// type MyExlude<T, K> = T extends K ? never : T;
// type MyReadonly2<T, K extends keyof T = keyof T> = { readonly [k in K]: T[k]} & { [k in MyExlude<keyof T, K>]: T[k] }

type MyReadonly2<T, K extends keyof T = keyof T> = {
  [p in keyof T as p extends K? never: p]: T[p]
} & {
  readonly [p in K]: T[p]
}